package com.example.artwindow.controller;

import cn.hutool.core.bean.BeanUtil;
import com.example.artwindow.domain.dto.CommentAddDTO;
import com.example.artwindow.domain.dto.CommentPageDTO;
import com.example.artwindow.domain.dto.CommentSelectDTO;
import com.example.artwindow.domain.dto.SubCommentSelectDTO;
import com.example.artwindow.domain.vo.CommentVO;
import com.example.artwindow.result.ListResult;
import com.example.artwindow.result.Result;
import com.example.artwindow.service.CommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.jdbc.Null;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
@Tag(name = "评论相关接口")
@Slf4j
@RequiredArgsConstructor
public class CommentController {
	
	private final CommentService commentService;
	
	@PostMapping()
	@Operation(summary = "发表评论")
	private Result<Null> commentR(@RequestBody CommentAddDTO commentAddDTO) {
		return commentService.commentAdd(commentAddDTO);
	}
	@GetMapping()
	@Operation(summary = "查看评论")
	private Result<ListResult<CommentVO>> commentPage(CommentSelectDTO commentSelectDTO){
		CommentPageDTO commentPageDTO = BeanUtil.copyProperties(commentSelectDTO, CommentPageDTO.class);
		return commentService.commentPage(commentPageDTO);
	}

	@GetMapping("/subComment")
	@Operation(summary = "查看子评论")
	private Result<ListResult<CommentVO>> subCommentPage(SubCommentSelectDTO subCommentSelectDTO){
		CommentPageDTO commentPageDTO = BeanUtil.copyProperties(subCommentSelectDTO, CommentPageDTO.class);
		return commentService.commentPage(commentPageDTO);
	}



}
